<?php
/**
 * @author Biju T biju@poornam.com
 *  
 */
require_once(dirname(__FILE__).'/../interface/ConfigManager.php');
require_once(dirname(__FILE__).'/../../packages/spyc/spyc.php');

class YAMLConfigManager implements ConfigManager{
	public $config = array();
	var $_configPath;
	public $globals = array();
	
	function YAMLConfigManager(){
		
	}
	
	private function defineGlobals($globals){
		foreach($globals as $global_outer){
			foreach($global_outer as $key=>$value){
				define(strtoupper($key),$value);
				$this->globals[$key] = $value;
			}
		}
	}
	
	public function loadConfig($path){
		//$this->config = Spyc::YAMLLoad(dirname(__FILE__)."/../../../config.yaml");
		$this->config = Spyc::YAMLLoad($path);
		//print_r("<pre>");print_r($this->config);
		if($this->config['globals'] != null)
			$this->defineGlobals($this->config['globals']);
		//if($config['libs'] != null)	
			//$this->loadLib($config['libs']);
		return 	$this->config;
	}
	
	public function getConfigPath(){
		
	}
	public function getConfig($property){
		return $this->config[$property];
	}
}
?>